package com.plian.system.service.pm.property;

import com.plian.Tools.CollectionUtil;
import com.plian.system.entity.pm.property.BaseContributor;
import com.plian.system.entity.pm.property.BasePartnerOutbound;
import com.plian.system.entity.pm.property.BasePartnerSituation;
import com.plian.system.entity.pm.property.BaseShareholding;

import java.util.List;

/**
 * @description:
 * @author: gangan
 * @create: 2021-05-20 15:48
 */
public class PropertyHelper {

    public static StringBuilder checkContributor(List<? extends BaseContributor> contributorList, List<String> existIds, int checkType){
        StringBuilder message = new StringBuilder();
        if (CollectionUtil.isEmpty(contributorList)){
            return message;
        }
        for (BaseContributor contributor : contributorList){
            String propertyId = "";
            switch (checkType){
                case 1:
                    propertyId = contributor.getPropertyId();
                    break;
                case 2:
                    propertyId = contributor.getPropertyDataSourceId();
                    break;
            }

            if (!existIds.contains(propertyId)){
                if (message.length() > 0){
                    message.append(",");
                }
                switch (checkType){
                    case 1:
                        message.append("出资人名称 = " + contributor.getContributor() +
                                "，propertyId = " + contributor.getPropertyId() + " 不存在");
                        break;
                    case 2:
                        message.append("出资人名称 = " + contributor.getContributor() +
                                "，propertyId = " + contributor.getPropertyDataSourceId() + " 不存在");
                        break;
                }

                continue;
            }
        }
        return message;
    }

    public static StringBuilder checkShareholding(List<? extends BaseShareholding> shareholdingList, List<String> existIds, int checkType){
        StringBuilder message = new StringBuilder();
        if (CollectionUtil.isEmpty(shareholdingList)){
            return message;
        }
        for (BaseShareholding shareholding : shareholdingList){
            String propertyId = "";
            switch (checkType){
                case 1:
                    propertyId = shareholding.getPropertyId();
                    break;
                case 2:
                    propertyId = shareholding.getPropertyDataSourceId();
                    break;
            }
            if (!existIds.contains(propertyId)){
                if (message.length() > 0){
                    message.append(",");
                }
                switch (checkType){
                    case 1:
                        message.append("境外控股人名称 = " + shareholding.getActualName() +
                                "，propertyId = " + shareholding.getPropertyId() + " 不存在");
                        break;
                    case 2:
                        message.append("境外控股人名称 = " + shareholding.getActualName() +
                                "，propertyId = " + shareholding.getPropertyDataSourceId() + " 不存在");
                        break;
                }
                continue;
            }
        }
        return message;
    }

    public static StringBuilder checkPartnerOutbound(List<? extends BasePartnerOutbound> partnerOutboundList, List<String> existIds, int checkType){
        StringBuilder message = new StringBuilder();
        if (CollectionUtil.isEmpty(partnerOutboundList)){
            return message;
        }
        for (BasePartnerOutbound partnerOutbound : partnerOutboundList){
            String propertyId = "";
            switch (checkType){
                case 1:
                    propertyId = partnerOutbound.getPropertyId();
                    break;
                case 2:
                    propertyId = partnerOutbound.getPropertyDataSourceId();
                    break;
            }
            if (!existIds.contains(propertyId)){
                if (message.length() > 0){
                    message.append(",");
                }
                switch (checkType){
                    case 1:
                        message.append("标的名称 = " + partnerOutbound.getName() +
                                "，propertyId = " + partnerOutbound.getPropertyId() + " 不存在");
                        break;
                    case 2:
                        message.append("标的名称 = " + partnerOutbound.getName() +
                                "，propertyId = " + partnerOutbound.getPropertyDataSourceId() + " 不存在");
                        break;
                }
                continue;
            }
        }
        return message;
    }

    public static StringBuilder checkPartnerSituation(List<? extends BasePartnerSituation> partnerSituationList, List<String> existIds, int checkType){
        StringBuilder message = new StringBuilder();
        if (CollectionUtil.isEmpty(partnerSituationList)){
            return message;
        }
        for (BasePartnerSituation partnerSituation : partnerSituationList){
            String propertyId = "";
            switch (checkType){
                case 1:
                    propertyId = partnerSituation.getPropertyId();
                    break;
                case 2:
                    propertyId = partnerSituation.getPropertyDataSourceId();
                    break;
            }
            if (!existIds.contains(propertyId)){
                if (message.length() > 0){
                    message.append(",");
                }
                switch (checkType){
                    case 1:
                        message.append("合伙人名称 = " + partnerSituation.getName() +
                                "，propertyId = " + partnerSituation.getPropertyId() + " 不存在");
                        break;
                    case 2:
                        message.append("合伙人名称 = " + partnerSituation.getName() +
                                "，propertyId = " + partnerSituation.getPropertyDataSourceId() + " 不存在");
                        break;
                }
                continue;
            }
        }
        return message;
    }
}
